<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="exporter-version" content="Evernote Mac 9.4.5 (461378)"/><meta name="author" content="704206198@qq.com"/><meta name="created" content="2020-10-25 15:30:43 +0000"/><meta name="source" content="desktop.mac"/><meta name="updated" content="2020-11-03 18:54:04 +0000"/><meta name="content-class" content="yinxiang.markdown"/><title>day13：vue项目 - 支付</title></head><body><div style="font-size: 14px; margin: 0; padding: 0; width: 100%;"><h1 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 41px; border-bottom: 3px double #999; color: #000; margin-top: 14px;">一、支付接口封装</h1>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">1. 支付方式：</h2>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><a href="https://pay.weixin.qq.com/index.php/core/home/login?return_url=%2F" style="line-height: 160%; box-sizing: content-box; text-decoration: underline; color: #5286bc;">微信支付</a></li>
</ul>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">2. <a href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5" style="line-height: 160%; box-sizing: content-box; text-decoration: underline; color: #5286bc;">支付的业务流程</a></h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><img src="day13%EF%BC%9Avue%E9%A1%B9%E7%9B%AE%20-%20%E6%94%AF%E4%BB%98.resources/chapter6_5_1.jpg" height="841" width="853"/></p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">业务流程说明：</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（1）商户后台系统根据用户选购的商品生成订单。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（2）用户确认支付后调用微信支付【统一下单API】生成预支付交易；</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（3）微信支付系统收到请求后生成预支付交易单，并返回交易会话的二维码链接code_url。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（4）商户后台系统根据返回的code_url生成二维码。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（5）用户打开微信“扫一扫”扫描二维码，微信客户端将扫码内容发送到微信支付系统。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（6）微信支付系统收到客户端请求，验证链接有效性后发起用户支付，要求用户授权。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（7）用户在微信客户端输入密码，确认支付后，微信客户端提交授权。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（8）微信支付系统根据用户授权完成支付交易。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（9）微信支付系统完成支付交易后给微信客户端返回交易结果，并将交易结果通过短信、微信消息提示用户。微信客户端展示支付交易结果页面。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（10）微信支付系统通过发送异步消息通知商户后台系统支付结果。商户后台系统需回复接收情况，通知微信后台系统不再发送该单的支付通知。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（11）未收到支付通知的情况，商户后台系统调用【查询订单API】。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">（12）商户确认订单已支付后给用户发货。</p>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">3. <a href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_1" style="line-height: 160%; box-sizing: content-box; text-decoration: underline; color: #5286bc;">统一下单接口</a> 介绍</h2>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">后台项目添加常用属性标的配置文件,这些配置均 不需要更改，直接使用接口，如果自己想配置，需要先申请公司，然后申请微信支付功能。</li>
</ul>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;"><span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// goods-admin/config/index.js</span>
<span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">module</span>.exports = {
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 统一下单接口地址</span>
  unifiedorder: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'https://api.mch.weixin.qq.com/pay/unifiedorder'</span>,
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 公众账号ID</span>
  appid: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'wx100749d4612ea385'</span>,
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 商户号</span>
  mch_id: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'1448624302'</span>,
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 支付结果的回调地址</span>
  notify_url: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'https://walter666.cn/wxpay/notify'</span>,
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 拼接API密钥</span>
  key: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'T8NHKqOfKWtqZPnQm8K77PtQtaRXluU8'</span>
}
</code></pre>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">4. 根据用户选购的商品，生成预支付交易单</h2>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">根据 统一下单接口 添加必须的属性，前端只需要 产品的描述 + 产品的订单id + 交易的金额。</li>
</ul>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">1. 必传属性表</h4>
<table style="margin: 2px 0 14px; color: #333; width: auto; border-collapse: collapse; box-sizing: border-box;"><thead style="line-height: 160%; box-sizing: content-box;"><tr style="line-height: 160%; box-sizing: content-box;"><th style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #72777b; border-top: 0; background-color: #7b8184; font-weight: 300; color: #fff; padding-top: 6px;">属性</th><th style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #72777b; border-top: 0; background-color: #7b8184; font-weight: 300; color: #fff; padding-top: 6px;">作用</th><th style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #72777b; border-top: 0; background-color: #7b8184; font-weight: 300; color: #fff; padding-top: 6px;">备注</th></tr></thead><tbody style="line-height: 160%; box-sizing: content-box;"><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">appid</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">公众号id</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">从配置中获取</td></tr><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">mch_id</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">商户号</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">从配置中获取</td></tr><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">nonce_str</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">随机字符串</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">随机字符串，长度要求在32位以内。推荐<a href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=4_3" style="line-height: 160%; box-sizing: content-box; text-decoration: underline; color: #5286bc;">随机数生成算法</a></td></tr><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">sign</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">签名</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">通过签名算法计算得出的签名值，详见<a href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=4_3" style="line-height: 160%; box-sizing: content-box; text-decoration: underline; color: #5286bc;">签名生成算法</a></td></tr><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">body</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">商品描述</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">商品简单描述，该字段请按照规范传递，具体请见<a href="https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=4_2" style="line-height: 160%; box-sizing: content-box; text-decoration: underline; color: #5286bc;">参数规定</a></td></tr><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">out_trade_no</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">商户订单号</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">商户系统内部订单号，要求32个字符内，只能是数字、大小写字母_-以及* 且在同一个商户号下唯一。</td></tr><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">total_fee</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">标价金额</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">订单总金额，单位为分</td></tr><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">notify_url</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">通知地址</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">从配置中获取</td></tr><tr style="line-height: 160%; box-sizing: content-box;"><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">trade_type</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">交易类型</td><td style="line-height: 160%; box-sizing: content-box;  padding: 5px 14px 5px 12px; border: 1px solid #eaeaea;">JSAPI -JSAPI支付NATIVE -Native支付APP -APP支付</td></tr></tbody></table>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">2.生成随机字符串</h4>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">微信支付API接口协议中包含字段nonce_str，主要保证签名不可预测。推荐生成随机数算法如下：调用随机数函数生成，将得到的值转换为字符串。</li>
</ul>
<ol style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">项目根目录下创建tools文件夹，在其下创建 tools.js</p>
</li>
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">安装随机字符串模块</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333; margin-top: 0; margin-bottom: 0;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><code style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; color: #c1788b; padding: 4px 4px 2px 0; letter-spacing: -.3px;">cnpm i randomstring -S</code></li>
</ul>
</li>
</ol>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;"><span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// goods-admin/tools/tools.js</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> randomstring = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'randomstring'</span>)
exports.getNoncestr = <span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;"><span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">()</span> =&gt;</span> {
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> randomstring.generate(<span style="color: #b8d7a3; line-height: 160%; box-sizing: content-box;">32</span>)
}
</code></pre>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">3.生产签名</h4>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">签名生成的通用步骤如下：</li>
</ul>
<ol style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">设所有发送或者接收到的数据为集合M，将集合M内非空参数值的参数按照参数名ASCII码从小到大排序（字典序），使用URL键值对的格式（即key1=value1&amp;key2=value2…）拼接成字符串stringA。<br/>
特别注意以下重要规则：<br/>
◆ 参数名ASCII码从小到大排序（字典序）；<br/>
◆ 如果参数的值为空不参与签名；<br/>
◆ 参数名区分大小写；<br/>
◆ 验证调用返回或微信主动通知签名时，传送的sign参数不参与签名，将生成的签名与该sign值作校验。<br/>
◆ 微信接口可能增加字段，验证签名时必须支持增加的扩展字段</p>
</li>
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">在stringA最后拼接上key得到stringSignTemp字符串，并对stringSignTemp进行MD5运算，再将得到的字符串所有字符转换为大写，得到sign值signValue。<br/>
◆ key设置路径：微信商户平台(pay.weixin.qq.com)--&gt;账户设置--&gt;API安全--&gt;密钥设置</p>
</li>
</ol>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;"><span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// goods-admin/tools/tools.js</span>
exports.getSign = <span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">M</span>) =&gt;</span> {
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> obj = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">Object</span>.keys(M).sort().reduce(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">obj, key</span>) =&gt;</span> {
      obj[key] = M[key]
      <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> obj
    }, {})
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> stringA = qs.stringify(obj, <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">null</span>, <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">null</span>, {
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">encodeURIComponent</span>: <span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">value</span>) =&gt;</span> {
        <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">decodeURIComponent</span>(value)
      }
    })
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> stringSignTemp = stringA + <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'&amp;key='</span> + config.key
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> signValue = md5(stringSignTemp).toUpperCase()
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> signValue
}
</code></pre>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">4.将必须的属性整合生成xml文件封装</h4>
<ol style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">安装 xml文件和js文件互转 模块
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333; margin-top: 0; margin-bottom: 0;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><code style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; color: #c1788b; padding: 4px 4px 2px 0; letter-spacing: -.3px;">cnpm i xml-js -S</code></li>
</ul>
</li>
</ol>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;"><span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// goods-admin/tools/tools.js</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> convert = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'xml-js'</span>)
exports.getXml = <span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">M, sign</span>) =&gt;</span> {
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> obj = {
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">xml</span>: {
        ...M,
        sign
      }
    }
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> xml = convert.js2xml(obj, {
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">compact</span>: <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">true</span>
    })
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> xml 
}
</code></pre>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">5. 使用axios发起 统一下单接口 请求</h2>
<ol style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">下载axios</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333; margin-top: 0; margin-bottom: 0;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><code style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; color: #c1788b; padding: 4px 4px 2px 0; letter-spacing: -.3px;">npm i axios -S</code></li>
</ul>
</li>
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">请求统一下单接口，得到支付地址，转成二维码形式，返回给前端</p>
</li>
</ol>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;">axios.post(config.unifiedorder, data).then(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;"><span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">response</span> =&gt;</span> {
    <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">console</span>.log(response.data)
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> xml = response.data

    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// xml 转为 js文件 获取 code_url 的值</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> payObj = tools.xml2js(xml)
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> code_url = payObj.code_url
    
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 支付地址  --  转换为二维码</span>
    qrcode.toDataURL(code_url, (err, data) =&gt; {
      res.send({
        <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">code</span>: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'200'</span>,
        <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">message</span>: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'支付二维码'</span>,
        data
      })
    })
})
</code></pre>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">6. 总结</h2>
<ol style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">商户信息：config/index.js</li>
</ol>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;"><span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">module</span>.exports = {
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 统一下单接口地址</span>
  unifiedorder: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'https://api.mch.weixin.qq.com/pay/unifiedorder'</span>,
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 公众账号ID</span>
  appid: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'wx100749d4612ea385'</span>,
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 商户号</span>
  mch_id: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'1448624302'</span>,
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 支付结果的回调地址</span>
  notify_url: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'https://walter666.cn/wxpay/notify'</span>,
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 拼接API密钥</span>
  key: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'T8NHKqOfKWtqZPnQm8K77PtQtaRXluU8'</span>
}
</code></pre>
<ol start="2" style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">工具文件：tools/tools.js</li>
</ol>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;"><span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> rendomstring = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'randomstring'</span>)  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 随机字符串</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> qs = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'querystring'</span>)     <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 解析query数据</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> md5 = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'md5'</span>)        <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// md5加密</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> config = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'./../config'</span>)     <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 商户的身份信息</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> convert = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'xml-js'</span>)     <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// xml &lt;===&gt; js</span>
<span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">module</span>.exports = {
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 获取随机字符</span>
  getNonceStr () {
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> rendomstring.generate(<span style="color: #b8d7a3; line-height: 160%; box-sizing: content-box;">32</span>)
  },
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 获取签名</span>
  getSign (M) {
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 将集合M内非空参数值的参数按照参数名ASCII码从小到大排序（字典序）</span>
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// M                               { appid, mch_id, nonce_str, notify_url, trade_type, body, out_trade_no, total_fee}</span>
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// return Object.keys(M).sort() // ["appid","body","mch_id","nonce_str","notify_url","out_trade_no","total_fee","trade_type"]</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> obj = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">Object</span>.keys(M).sort().reduce(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">obj, key</span>) =&gt;</span> {
      obj[key] = M[key]
      <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> obj
    }, {})
    
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// return obj</span>
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 使用URL键值对的格式（即key1=value1&amp;key2=value2…）拼接成字符串stringA。</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> stringA = qs.stringify(obj, <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">null</span>, <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">null</span>, {
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">encodeURIComponent</span>: <span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">value</span>) =&gt;</span> {
        <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">decodeURIComponent</span>(value)
      }
    })
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// appid=wx100749d4612ea385&amp;body=%E4%B8%80%E7%93%B6%E5%8F%AF%E4%B9%90&amp;mch_id=1448624302&amp;nonce_str=UWUUhSMOtwtlknfUvRHmWAXRaeRJhq1Y¬ify_url=https%3A%2F%2Fwalter666.cn%2Fwxpay%2Fnotify&amp;out_trade_no=aavbb__1&amp;total_fee=1&amp;trade_type=Native</span>
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// return stringA</span>
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 在stringA最后拼接上key得到 stringSignTemp 字符串</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> stringSignTemp = stringA + <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'&amp;key='</span> + config.key
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// stringSignTemp进行MD5运算，再将得到的字符串所有字符转换为大写，得到sign值 signValue。</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> signValue = md5(stringSignTemp).toUpperCase()
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> signValue
  },
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 获取xml数据</span>
  getXml (M, sign) {
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> obj = {
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">xml</span>: {
        ...M,
        sign
      }
    }
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// {"xml":{"appid":"wx100749d4612ea385","mch_id":"1448624302","nonce_str":"TwlZGCT2ipT9ufBxUGN15yg1AuGudsWM","notify_url":"https://walter666.cn/wxpay/notify","trade_type":"Native","body":"一瓶可乐","out_trade_no":"aavbb__1","total_fee":1,"sign":"DFAAA8968FD6F6BD86E998BE6AB07989"}}</span>
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// return obj</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> xml = convert.js2xml(obj, {
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">compact</span>: <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">true</span>
    })
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// &lt;xml&gt;&lt;appid&gt;wx100749d4612ea385&lt;/appid&gt;&lt;mch_id&gt;1448624302&lt;/mch_id&gt;&lt;nonce_str&gt;lUrP3sg21DJCm0ckCe2KlQ6eB8LUE5vZ&lt;/nonce_str&gt;&lt;notify_url&gt;https://walter666.cn/wxpay/notify&lt;/notify_url&gt;&lt;trade_type&gt;Native&lt;/trade_type&gt;&lt;body&gt;一瓶可乐&lt;/body&gt;&lt;out_trade_no&gt;aavbb__1&lt;/out_trade_no&gt;&lt;total_fee&gt;1&lt;/total_fee&gt;&lt;sign&gt;002F2F7EFAB1270A093A94109D848883&lt;/sign&gt;&lt;/xml&gt;</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> xml 
  },
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 将xml数据转成js数据</span>
  xml2js (xml) {
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> obj = convert.xml2js(xml, {
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">compact</span>: <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">true</span>,
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">textKey</span>: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'value'</span>,
      <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">cdataKey</span>: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'value'</span>
    })
    
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// return obj</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> dataObjArr = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">Object</span>.keys(obj.xml).sort()
    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// ["appid","code_url","mch_id","nonce_str","prepay_id","result_code","return_code","return_msg","sign","trade_type"]</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> dataObj = dataObjArr.reduce(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">obj1, key</span>) =&gt;</span> {
      obj1[key] = obj.xml[key][<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'value'</span>]
      <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> obj1
    }, {})
    
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">return</span> dataObj
  }
}
</code></pre>
<ol start="3" style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">接口文件：api/order.js</li>
</ol>
<pre style="line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; margin: 2px 0 8px; background-color: #f5f7f8;"><code style="display: block; overflow-x: auto; background: #1e1e1e; line-height: 160%; box-sizing: content-box; border: 0; border-radius: 0; letter-spacing: -.3px; padding: 18px; color: #f4f4f4; white-space: pre-wrap;"><span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> config = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'./../config'</span>)     <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 商户的身份信息</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> tools = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'./../utils/tools'</span>)     <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 工具文件</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> axios = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'axios'</span>)        <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 数据请求</span>
<span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">var</span> qrcode = <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">require</span>(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'qrcode'</span>)      <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 地址转成二维码</span>
router.get(<span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'/payment'</span>, (req, res, next) =&gt; {
  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">let</span> { body, out_trade_no, total_fee } = req.query
  body = <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">"一瓶可乐"</span> <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 商品描述</span>
  out_trade_no = <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">"aabbcc_1"</span> <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 商户的订单编号</span>
  total_fee = <span style="color: #b8d7a3; line-height: 160%; box-sizing: content-box;">1</span> <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 支付金额，分</span>

  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> appid = config.appid     <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 公众号id</span>
  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> mch_id = config.mch_id   <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 商户号</span>
  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> nonce_str =  tools.getNonceStr()	 <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 随机字符串 randomstring</span>
  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> notify_url = config.notify_url <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 支付结果的回调地址</span>
  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> trade_type = <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">"NATIVE"</span>	<span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 交易类型</span>
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 设所有发送或者接收到的数据为集合M，</span>
  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> M = {
    appid, mch_id, nonce_str, notify_url, trade_type, body, out_trade_no, total_fee
  }
  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> sign = tools.getSign(M)  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 签名</span>

  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 参数转换成为xml文件，支付 参数形式为xml格式  ---  对象的key值为标签，value的值为 标签的内容</span>
  <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 调用接口需要传递的数据</span>
  <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> data = tools.getXml(M, sign)
  axios.post(config.unifiedorder, data).then(<span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;"><span style="color: #dcdcdc; line-height: 160%; box-sizing: content-box;">response</span> =&gt;</span> {
    <span style="color: #4ec9b0; line-height: 160%; box-sizing: content-box;">console</span>.log(response.data)
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> xml = response.data

    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// xml 转为 js文件 获取 code_url 的值</span>
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> payObj = tools.xml2js(xml)
    <span style="color: #569cd6; line-height: 160%; box-sizing: content-box;">const</span> code_url = payObj.code_url

    <span style="color: #57a64a; font-style: italic; line-height: 160%; box-sizing: content-box;">// 支付地址  --  转换为二维码</span>
    qrcode.toDataURL(code_url, (err, data) =&gt; {
      res.send({
        <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">state</span>: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'200'</span>,
        <span style="color: #9cdcfe; line-height: 160%; box-sizing: content-box;">title</span>: <span style="color: #d69d85; line-height: 160%; box-sizing: content-box;">'支付二维码'</span>,
        data
      })
    })
  })
})
</code></pre>
<h1 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 41px; border-bottom: 3px double #999; color: #000;">二、前端调用接口</h1>
<ol style="line-height: 160%; box-sizing: content-box; display: block; padding-left: 30px; margin: 6px 0 10px; color: #333; list-style-type: decimal;">
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">封装接口方法</p>
</li>
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">去支付页面，引入方法</p>
</li>
<li style="line-height: 160%; box-sizing: content-box;">
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">点击支付，调用方法，发送数据</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333; margin-top: 0; margin-bottom: 0;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">body：商品描述</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">out_trade_no：订单编号</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">total_fee：付款金额，分</li>
</ul>
</li>
</ol>
<h1 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 41px; border-bottom: 3px double #999; color: #000;"/>
</div><center style="display:none !important;visibility:collapse !important;height:0 !important;white-space:nowrap;width:100%;overflow:hidden">%23%20%E4%B8%80%E3%80%81%E6%94%AF%E4%BB%98%E6%8E%A5%E5%8F%A3%E5%B0%81%E8%A3%85%0A%23%23%201.%20%E6%94%AF%E4%BB%98%E6%96%B9%E5%BC%8F%EF%BC%9A%0A-%20%5B%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%5D(https%3A%2F%2Fpay.weixin.qq.com%2Findex.php%2Fcore%2Fhome%2Flogin%3Freturn_url%3D%252F)%0A%0A%23%23%202.%20%5B%E6%94%AF%E4%BB%98%E7%9A%84%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B%5D(https%3A%2F%2Fpay.weixin.qq.com%2Fwiki%2Fdoc%2Fapi%2Fnative.php%3Fchapter%3D6_5)%0A!%5Ba763408a7b3d336d46952453d635bd37.jpeg%5D(evernotecid%3A%2F%2FBB210BE9-3A02-4842-A4C9-7970C5C1E576%2Fappyinxiangcom%2F16639017%2FENResource%2Fp732)%0A%0A-%20%E4%B8%9A%E5%8A%A1%E6%B5%81%E7%A8%8B%E8%AF%B4%E6%98%8E%EF%BC%9A%0A%0A%EF%BC%881%EF%BC%89%E5%95%86%E6%88%B7%E5%90%8E%E5%8F%B0%E7%B3%BB%E7%BB%9F%E6%A0%B9%E6%8D%AE%E7%94%A8%E6%88%B7%E9%80%89%E8%B4%AD%E7%9A%84%E5%95%86%E5%93%81%E7%94%9F%E6%88%90%E8%AE%A2%E5%8D%95%E3%80%82%0A%0A%EF%BC%882%EF%BC%89%E7%94%A8%E6%88%B7%E7%A1%AE%E8%AE%A4%E6%94%AF%E4%BB%98%E5%90%8E%E8%B0%83%E7%94%A8%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E3%80%90%E7%BB%9F%E4%B8%80%E4%B8%8B%E5%8D%95API%E3%80%91%E7%94%9F%E6%88%90%E9%A2%84%E6%94%AF%E4%BB%98%E4%BA%A4%E6%98%93%EF%BC%9B%0A%0A%EF%BC%883%EF%BC%89%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E7%B3%BB%E7%BB%9F%E6%94%B6%E5%88%B0%E8%AF%B7%E6%B1%82%E5%90%8E%E7%94%9F%E6%88%90%E9%A2%84%E6%94%AF%E4%BB%98%E4%BA%A4%E6%98%93%E5%8D%95%EF%BC%8C%E5%B9%B6%E8%BF%94%E5%9B%9E%E4%BA%A4%E6%98%93%E4%BC%9A%E8%AF%9D%E7%9A%84%E4%BA%8C%E7%BB%B4%E7%A0%81%E9%93%BE%E6%8E%A5code_url%E3%80%82%0A%0A%EF%BC%884%EF%BC%89%E5%95%86%E6%88%B7%E5%90%8E%E5%8F%B0%E7%B3%BB%E7%BB%9F%E6%A0%B9%E6%8D%AE%E8%BF%94%E5%9B%9E%E7%9A%84code_url%E7%94%9F%E6%88%90%E4%BA%8C%E7%BB%B4%E7%A0%81%E3%80%82%0A%0A%EF%BC%885%EF%BC%89%E7%94%A8%E6%88%B7%E6%89%93%E5%BC%80%E5%BE%AE%E4%BF%A1%E2%80%9C%E6%89%AB%E4%B8%80%E6%89%AB%E2%80%9D%E6%89%AB%E6%8F%8F%E4%BA%8C%E7%BB%B4%E7%A0%81%EF%BC%8C%E5%BE%AE%E4%BF%A1%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%B0%86%E6%89%AB%E7%A0%81%E5%86%85%E5%AE%B9%E5%8F%91%E9%80%81%E5%88%B0%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E7%B3%BB%E7%BB%9F%E3%80%82%0A%0A%EF%BC%886%EF%BC%89%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E7%B3%BB%E7%BB%9F%E6%94%B6%E5%88%B0%E5%AE%A2%E6%88%B7%E7%AB%AF%E8%AF%B7%E6%B1%82%EF%BC%8C%E9%AA%8C%E8%AF%81%E9%93%BE%E6%8E%A5%E6%9C%89%E6%95%88%E6%80%A7%E5%90%8E%E5%8F%91%E8%B5%B7%E7%94%A8%E6%88%B7%E6%94%AF%E4%BB%98%EF%BC%8C%E8%A6%81%E6%B1%82%E7%94%A8%E6%88%B7%E6%8E%88%E6%9D%83%E3%80%82%0A%0A%EF%BC%887%EF%BC%89%E7%94%A8%E6%88%B7%E5%9C%A8%E5%BE%AE%E4%BF%A1%E5%AE%A2%E6%88%B7%E7%AB%AF%E8%BE%93%E5%85%A5%E5%AF%86%E7%A0%81%EF%BC%8C%E7%A1%AE%E8%AE%A4%E6%94%AF%E4%BB%98%E5%90%8E%EF%BC%8C%E5%BE%AE%E4%BF%A1%E5%AE%A2%E6%88%B7%E7%AB%AF%E6%8F%90%E4%BA%A4%E6%8E%88%E6%9D%83%E3%80%82%0A%0A%EF%BC%888%EF%BC%89%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E7%B3%BB%E7%BB%9F%E6%A0%B9%E6%8D%AE%E7%94%A8%E6%88%B7%E6%8E%88%E6%9D%83%E5%AE%8C%E6%88%90%E6%94%AF%E4%BB%98%E4%BA%A4%E6%98%93%E3%80%82%0A%0A%EF%BC%889%EF%BC%89%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E7%B3%BB%E7%BB%9F%E5%AE%8C%E6%88%90%E6%94%AF%E4%BB%98%E4%BA%A4%E6%98%93%E5%90%8E%E7%BB%99%E5%BE%AE%E4%BF%A1%E5%AE%A2%E6%88%B7%E7%AB%AF%E8%BF%94%E5%9B%9E%E4%BA%A4%E6%98%93%E7%BB%93%E6%9E%9C%EF%BC%8C%E5%B9%B6%E5%B0%86%E4%BA%A4%E6%98%93%E7%BB%93%E6%9E%9C%E9%80%9A%E8%BF%87%E7%9F%AD%E4%BF%A1%E3%80%81%E5%BE%AE%E4%BF%A1%E6%B6%88%E6%81%AF%E6%8F%90%E7%A4%BA%E7%94%A8%E6%88%B7%E3%80%82%E5%BE%AE%E4%BF%A1%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%B1%95%E7%A4%BA%E6%94%AF%E4%BB%98%E4%BA%A4%E6%98%93%E7%BB%93%E6%9E%9C%E9%A1%B5%E9%9D%A2%E3%80%82%0A%0A%EF%BC%8810%EF%BC%89%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E7%B3%BB%E7%BB%9F%E9%80%9A%E8%BF%87%E5%8F%91%E9%80%81%E5%BC%82%E6%AD%A5%E6%B6%88%E6%81%AF%E9%80%9A%E7%9F%A5%E5%95%86%E6%88%B7%E5%90%8E%E5%8F%B0%E7%B3%BB%E7%BB%9F%E6%94%AF%E4%BB%98%E7%BB%93%E6%9E%9C%E3%80%82%E5%95%86%E6%88%B7%E5%90%8E%E5%8F%B0%E7%B3%BB%E7%BB%9F%E9%9C%80%E5%9B%9E%E5%A4%8D%E6%8E%A5%E6%94%B6%E6%83%85%E5%86%B5%EF%BC%8C%E9%80%9A%E7%9F%A5%E5%BE%AE%E4%BF%A1%E5%90%8E%E5%8F%B0%E7%B3%BB%E7%BB%9F%E4%B8%8D%E5%86%8D%E5%8F%91%E9%80%81%E8%AF%A5%E5%8D%95%E7%9A%84%E6%94%AF%E4%BB%98%E9%80%9A%E7%9F%A5%E3%80%82%0A%0A%EF%BC%8811%EF%BC%89%E6%9C%AA%E6%94%B6%E5%88%B0%E6%94%AF%E4%BB%98%E9%80%9A%E7%9F%A5%E7%9A%84%E6%83%85%E5%86%B5%EF%BC%8C%E5%95%86%E6%88%B7%E5%90%8E%E5%8F%B0%E7%B3%BB%E7%BB%9F%E8%B0%83%E7%94%A8%E3%80%90%E6%9F%A5%E8%AF%A2%E8%AE%A2%E5%8D%95API%E3%80%91%E3%80%82%0A%0A%EF%BC%8812%EF%BC%89%E5%95%86%E6%88%B7%E7%A1%AE%E8%AE%A4%E8%AE%A2%E5%8D%95%E5%B7%B2%E6%94%AF%E4%BB%98%E5%90%8E%E7%BB%99%E7%94%A8%E6%88%B7%E5%8F%91%E8%B4%A7%E3%80%82%0A%0A%0A%23%23%203.%20%5B%E7%BB%9F%E4%B8%80%E4%B8%8B%E5%8D%95%E6%8E%A5%E5%8F%A3%5D(https%3A%2F%2Fpay.weixin.qq.com%2Fwiki%2Fdoc%2Fapi%2Fnative.php%3Fchapter%3D9_1)%20%E4%BB%8B%E7%BB%8D%0A-%20%E5%90%8E%E5%8F%B0%E9%A1%B9%E7%9B%AE%E6%B7%BB%E5%8A%A0%E5%B8%B8%E7%94%A8%E5%B1%9E%E6%80%A7%E6%A0%87%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%2C%E8%BF%99%E4%BA%9B%E9%85%8D%E7%BD%AE%E5%9D%87%20%E4%B8%8D%E9%9C%80%E8%A6%81%E6%9B%B4%E6%94%B9%EF%BC%8C%E7%9B%B4%E6%8E%A5%E4%BD%BF%E7%94%A8%E6%8E%A5%E5%8F%A3%EF%BC%8C%E5%A6%82%E6%9E%9C%E8%87%AA%E5%B7%B1%E6%83%B3%E9%85%8D%E7%BD%AE%EF%BC%8C%E9%9C%80%E8%A6%81%E5%85%88%E7%94%B3%E8%AF%B7%E5%85%AC%E5%8F%B8%EF%BC%8C%E7%84%B6%E5%90%8E%E7%94%B3%E8%AF%B7%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98%E5%8A%9F%E8%83%BD%E3%80%82%0A%0A%60%60%60js%0A%2F%2F%20goods-admin%2Fconfig%2Findex.js%0Amodule.exports%20%3D%20%7B%0A%20%20%2F%2F%20%E7%BB%9F%E4%B8%80%E4%B8%8B%E5%8D%95%E6%8E%A5%E5%8F%A3%E5%9C%B0%E5%9D%80%0A%20%20unifiedorder%3A%20'https%3A%2F%2Fapi.mch.weixin.qq.com%2Fpay%2Funifiedorder'%2C%0A%20%20%2F%2F%20%E5%85%AC%E4%BC%97%E8%B4%A6%E5%8F%B7ID%0A%20%20appid%3A%20'wx100749d4612ea385'%2C%0A%20%20%2F%2F%20%E5%95%86%E6%88%B7%E5%8F%B7%0A%20%20mch_id%3A%20'1448624302'%2C%0A%20%20%2F%2F%20%E6%94%AF%E4%BB%98%E7%BB%93%E6%9E%9C%E7%9A%84%E5%9B%9E%E8%B0%83%E5%9C%B0%E5%9D%80%0A%20%20notify_url%3A%20'https%3A%2F%2Fwalter666.cn%2Fwxpay%2Fnotify'%2C%0A%20%20%2F%2F%20%E6%8B%BC%E6%8E%A5API%E5%AF%86%E9%92%A5%0A%20%20key%3A%20'T8NHKqOfKWtqZPnQm8K77PtQtaRXluU8'%0A%7D%0A%60%60%60%0A%0A%0A%23%23%204.%20%E6%A0%B9%E6%8D%AE%E7%94%A8%E6%88%B7%E9%80%89%E8%B4%AD%E7%9A%84%E5%95%86%E5%93%81%EF%BC%8C%E7%94%9F%E6%88%90%E9%A2%84%E6%94%AF%E4%BB%98%E4%BA%A4%E6%98%93%E5%8D%95%0A-%20%E6%A0%B9%E6%8D%AE%20%E7%BB%9F%E4%B8%80%E4%B8%8B%E5%8D%95%E6%8E%A5%E5%8F%A3%20%E6%B7%BB%E5%8A%A0%E5%BF%85%E9%A1%BB%E7%9A%84%E5%B1%9E%E6%80%A7%EF%BC%8C%E5%89%8D%E7%AB%AF%E5%8F%AA%E9%9C%80%E8%A6%81%20%E4%BA%A7%E5%93%81%E7%9A%84%E6%8F%8F%E8%BF%B0%20%2B%20%E4%BA%A7%E5%93%81%E7%9A%84%E8%AE%A2%E5%8D%95id%20%2B%20%E4%BA%A4%E6%98%93%E7%9A%84%E9%87%91%E9%A2%9D%E3%80%82%0A%0A%23%23%23%23%201.%20%E5%BF%85%E4%BC%A0%E5%B1%9E%E6%80%A7%E8%A1%A8%0A%0A%7C%20%E5%B1%9E%E6%80%A7%20%7C%20%E4%BD%9C%E7%94%A8%20%20%7C%20%E5%A4%87%E6%B3%A8%20%20%7C%0A%7C%20---%20%7C%20---%20%7C%20---%20%7C%0A%7C%20appid%20%7C%20%E5%85%AC%E4%BC%97%E5%8F%B7id%20%7C%20%E4%BB%8E%E9%85%8D%E7%BD%AE%E4%B8%AD%E8%8E%B7%E5%8F%96%20%7C%0A%7C%20mch_id%20%7C%20%E5%95%86%E6%88%B7%E5%8F%B7%20%20%7C%20%E4%BB%8E%E9%85%8D%E7%BD%AE%E4%B8%AD%E8%8E%B7%E5%8F%96%20%7C%0A%7C%20nonce_str%20%7C%20%E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%20%7C%20%E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%EF%BC%8C%E9%95%BF%E5%BA%A6%E8%A6%81%E6%B1%82%E5%9C%A832%E4%BD%8D%E4%BB%A5%E5%86%85%E3%80%82%E6%8E%A8%E8%8D%90%5B%E9%9A%8F%E6%9C%BA%E6%95%B0%E7%94%9F%E6%88%90%E7%AE%97%E6%B3%95%5D(https%3A%2F%2Fpay.weixin.qq.com%2Fwiki%2Fdoc%2Fapi%2Fnative.php%3Fchapter%3D4_3)%20%7C%0A%7C%20sign%20%7C%20%E7%AD%BE%E5%90%8D%20%7C%20%E9%80%9A%E8%BF%87%E7%AD%BE%E5%90%8D%E7%AE%97%E6%B3%95%E8%AE%A1%E7%AE%97%E5%BE%97%E5%87%BA%E7%9A%84%E7%AD%BE%E5%90%8D%E5%80%BC%EF%BC%8C%E8%AF%A6%E8%A7%81%5B%E7%AD%BE%E5%90%8D%E7%94%9F%E6%88%90%E7%AE%97%E6%B3%95%5D(https%3A%2F%2Fpay.weixin.qq.com%2Fwiki%2Fdoc%2Fapi%2Fnative.php%3Fchapter%3D4_3)%20%7C%0A%7C%20body%20%7C%20%E5%95%86%E5%93%81%E6%8F%8F%E8%BF%B0%20%7C%20%E5%95%86%E5%93%81%E7%AE%80%E5%8D%95%E6%8F%8F%E8%BF%B0%EF%BC%8C%E8%AF%A5%E5%AD%97%E6%AE%B5%E8%AF%B7%E6%8C%89%E7%85%A7%E8%A7%84%E8%8C%83%E4%BC%A0%E9%80%92%EF%BC%8C%E5%85%B7%E4%BD%93%E8%AF%B7%E8%A7%81%5B%E5%8F%82%E6%95%B0%E8%A7%84%E5%AE%9A%5D(https%3A%2F%2Fpay.weixin.qq.com%2Fwiki%2Fdoc%2Fapi%2Fnative.php%3Fchapter%3D4_2)%20%7C%20%0A%7C%20out_trade_no%20%7C%20%20%E5%95%86%E6%88%B7%E8%AE%A2%E5%8D%95%E5%8F%B7%20%7C%20%E5%95%86%E6%88%B7%E7%B3%BB%E7%BB%9F%E5%86%85%E9%83%A8%E8%AE%A2%E5%8D%95%E5%8F%B7%EF%BC%8C%E8%A6%81%E6%B1%8232%E4%B8%AA%E5%AD%97%E7%AC%A6%E5%86%85%EF%BC%8C%E5%8F%AA%E8%83%BD%E6%98%AF%E6%95%B0%E5%AD%97%E3%80%81%E5%A4%A7%E5%B0%8F%E5%86%99%E5%AD%97%E6%AF%8D_-%E4%BB%A5%E5%8F%8A*%20%E4%B8%94%E5%9C%A8%E5%90%8C%E4%B8%80%E4%B8%AA%E5%95%86%E6%88%B7%E5%8F%B7%E4%B8%8B%E5%94%AF%E4%B8%80%E3%80%82%7C%0A%7C%20total_fee%20%7C%20%E6%A0%87%E4%BB%B7%E9%87%91%E9%A2%9D%20%7C%20%E8%AE%A2%E5%8D%95%E6%80%BB%E9%87%91%E9%A2%9D%EF%BC%8C%E5%8D%95%E4%BD%8D%E4%B8%BA%E5%88%86%20%7C%0A%7C%20notify_url%20%7C%20%E9%80%9A%E7%9F%A5%E5%9C%B0%E5%9D%80%20%7C%20%E4%BB%8E%E9%85%8D%E7%BD%AE%E4%B8%AD%E8%8E%B7%E5%8F%96%20%7C%0A%7C%20trade_type%20%7C%20%E4%BA%A4%E6%98%93%E7%B1%BB%E5%9E%8B%20%7C%20JSAPI%20-JSAPI%E6%94%AF%E4%BB%98NATIVE%20-Native%E6%94%AF%E4%BB%98APP%20-APP%E6%94%AF%E4%BB%98%20%7C%0A%0A%23%23%23%23%202.%E7%94%9F%E6%88%90%E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%0A%0A-%20%E5%BE%AE%E4%BF%A1%E6%94%AF%E4%BB%98API%E6%8E%A5%E5%8F%A3%E5%8D%8F%E8%AE%AE%E4%B8%AD%E5%8C%85%E5%90%AB%E5%AD%97%E6%AE%B5nonce_str%EF%BC%8C%E4%B8%BB%E8%A6%81%E4%BF%9D%E8%AF%81%E7%AD%BE%E5%90%8D%E4%B8%8D%E5%8F%AF%E9%A2%84%E6%B5%8B%E3%80%82%E6%8E%A8%E8%8D%90%E7%94%9F%E6%88%90%E9%9A%8F%E6%9C%BA%E6%95%B0%E7%AE%97%E6%B3%95%E5%A6%82%E4%B8%8B%EF%BC%9A%E8%B0%83%E7%94%A8%E9%9A%8F%E6%9C%BA%E6%95%B0%E5%87%BD%E6%95%B0%E7%94%9F%E6%88%90%EF%BC%8C%E5%B0%86%E5%BE%97%E5%88%B0%E7%9A%84%E5%80%BC%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%E3%80%82%0A%0A1.%20%E9%A1%B9%E7%9B%AE%E6%A0%B9%E7%9B%AE%E5%BD%95%E4%B8%8B%E5%88%9B%E5%BB%BAtools%E6%96%87%E4%BB%B6%E5%A4%B9%EF%BC%8C%E5%9C%A8%E5%85%B6%E4%B8%8B%E5%88%9B%E5%BB%BA%20tools.js%0A%0A2.%20%E5%AE%89%E8%A3%85%E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%A8%A1%E5%9D%97%0A%20%20%20%20-%20%60cnpm%20i%20randomstring%20-S%60%0A%0A%60%60%60js%0A%2F%2F%20goods-admin%2Ftools%2Ftools.js%0Avar%20randomstring%20%3D%20require('randomstring')%0Aexports.getNoncestr%20%3D%20()%20%3D%3E%20%7B%0A%20%20%20%20return%20randomstring.generate(32)%0A%7D%0A%60%60%60%0A%0A%23%23%23%23%203.%E7%94%9F%E4%BA%A7%E7%AD%BE%E5%90%8D%0A-%20%E7%AD%BE%E5%90%8D%E7%94%9F%E6%88%90%E7%9A%84%E9%80%9A%E7%94%A8%E6%AD%A5%E9%AA%A4%E5%A6%82%E4%B8%8B%EF%BC%9A%0A1.%20%E8%AE%BE%E6%89%80%E6%9C%89%E5%8F%91%E9%80%81%E6%88%96%E8%80%85%E6%8E%A5%E6%94%B6%E5%88%B0%E7%9A%84%E6%95%B0%E6%8D%AE%E4%B8%BA%E9%9B%86%E5%90%88M%EF%BC%8C%E5%B0%86%E9%9B%86%E5%90%88M%E5%86%85%E9%9D%9E%E7%A9%BA%E5%8F%82%E6%95%B0%E5%80%BC%E7%9A%84%E5%8F%82%E6%95%B0%E6%8C%89%E7%85%A7%E5%8F%82%E6%95%B0%E5%90%8DASCII%E7%A0%81%E4%BB%8E%E5%B0%8F%E5%88%B0%E5%A4%A7%E6%8E%92%E5%BA%8F%EF%BC%88%E5%AD%97%E5%85%B8%E5%BA%8F%EF%BC%89%EF%BC%8C%E4%BD%BF%E7%94%A8URL%E9%94%AE%E5%80%BC%E5%AF%B9%E7%9A%84%E6%A0%BC%E5%BC%8F%EF%BC%88%E5%8D%B3key1%3Dvalue1%26key2%3Dvalue2%E2%80%A6%EF%BC%89%E6%8B%BC%E6%8E%A5%E6%88%90%E5%AD%97%E7%AC%A6%E4%B8%B2stringA%E3%80%82%0A%20%20%20%20%E7%89%B9%E5%88%AB%E6%B3%A8%E6%84%8F%E4%BB%A5%E4%B8%8B%E9%87%8D%E8%A6%81%E8%A7%84%E5%88%99%EF%BC%9A%0A%20%20%20%20%E2%97%86%20%E5%8F%82%E6%95%B0%E5%90%8DASCII%E7%A0%81%E4%BB%8E%E5%B0%8F%E5%88%B0%E5%A4%A7%E6%8E%92%E5%BA%8F%EF%BC%88%E5%AD%97%E5%85%B8%E5%BA%8F%EF%BC%89%EF%BC%9B%0A%20%20%20%20%E2%97%86%20%E5%A6%82%E6%9E%9C%E5%8F%82%E6%95%B0%E7%9A%84%E5%80%BC%E4%B8%BA%E7%A9%BA%E4%B8%8D%E5%8F%82%E4%B8%8E%E7%AD%BE%E5%90%8D%EF%BC%9B%0A%20%20%20%20%E2%97%86%20%E5%8F%82%E6%95%B0%E5%90%8D%E5%8C%BA%E5%88%86%E5%A4%A7%E5%B0%8F%E5%86%99%EF%BC%9B%0A%20%20%20%20%E2%97%86%20%E9%AA%8C%E8%AF%81%E8%B0%83%E7%94%A8%E8%BF%94%E5%9B%9E%E6%88%96%E5%BE%AE%E4%BF%A1%E4%B8%BB%E5%8A%A8%E9%80%9A%E7%9F%A5%E7%AD%BE%E5%90%8D%E6%97%B6%EF%BC%8C%E4%BC%A0%E9%80%81%E7%9A%84sign%E5%8F%82%E6%95%B0%E4%B8%8D%E5%8F%82%E4%B8%8E%E7%AD%BE%E5%90%8D%EF%BC%8C%E5%B0%86%E7%94%9F%E6%88%90%E7%9A%84%E7%AD%BE%E5%90%8D%E4%B8%8E%E8%AF%A5sign%E5%80%BC%E4%BD%9C%E6%A0%A1%E9%AA%8C%E3%80%82%0A%20%20%20%20%E2%97%86%20%E5%BE%AE%E4%BF%A1%E6%8E%A5%E5%8F%A3%E5%8F%AF%E8%83%BD%E5%A2%9E%E5%8A%A0%E5%AD%97%E6%AE%B5%EF%BC%8C%E9%AA%8C%E8%AF%81%E7%AD%BE%E5%90%8D%E6%97%B6%E5%BF%85%E9%A1%BB%E6%94%AF%E6%8C%81%E5%A2%9E%E5%8A%A0%E7%9A%84%E6%89%A9%E5%B1%95%E5%AD%97%E6%AE%B5%0A%0A2.%20%E5%9C%A8stringA%E6%9C%80%E5%90%8E%E6%8B%BC%E6%8E%A5%E4%B8%8Akey%E5%BE%97%E5%88%B0stringSignTemp%E5%AD%97%E7%AC%A6%E4%B8%B2%EF%BC%8C%E5%B9%B6%E5%AF%B9stringSignTemp%E8%BF%9B%E8%A1%8CMD5%E8%BF%90%E7%AE%97%EF%BC%8C%E5%86%8D%E5%B0%86%E5%BE%97%E5%88%B0%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%89%80%E6%9C%89%E5%AD%97%E7%AC%A6%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%A4%A7%E5%86%99%EF%BC%8C%E5%BE%97%E5%88%B0sign%E5%80%BCsignValue%E3%80%82%0A%20%20%20%20%E2%97%86%20key%E8%AE%BE%E7%BD%AE%E8%B7%AF%E5%BE%84%EF%BC%9A%E5%BE%AE%E4%BF%A1%E5%95%86%E6%88%B7%E5%B9%B3%E5%8F%B0(pay.weixin.qq.com)--%3E%E8%B4%A6%E6%88%B7%E8%AE%BE%E7%BD%AE--%3EAPI%E5%AE%89%E5%85%A8--%3E%E5%AF%86%E9%92%A5%E8%AE%BE%E7%BD%AE%0A%0A%60%60%60js%0A%2F%2F%20goods-admin%2Ftools%2Ftools.js%0Aexports.getSign%20%3D%20(M)%20%3D%3E%20%7B%0A%20%20%20%20const%20obj%20%3D%20Object.keys(M).sort().reduce((obj%2C%20key)%20%3D%3E%20%7B%0A%20%20%20%20%20%20obj%5Bkey%5D%20%3D%20M%5Bkey%5D%0A%20%20%20%20%20%20return%20obj%0A%20%20%20%20%7D%2C%20%7B%7D)%0A%20%20%20%20const%20stringA%20%3D%20qs.stringify(obj%2C%20null%2C%20null%2C%20%7B%0A%20%20%20%20%20%20encodeURIComponent%3A%20(value)%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20return%20decodeURIComponent(value)%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D)%0A%20%20%20%20const%20stringSignTemp%20%3D%20stringA%20%2B%20'%26key%3D'%20%2B%20config.key%0A%20%20%20%20const%20signValue%20%3D%20md5(stringSignTemp).toUpperCase()%0A%20%20%20%20return%20signValue%0A%7D%0A%60%60%60%0A%0A%23%23%23%23%204.%E5%B0%86%E5%BF%85%E9%A1%BB%E7%9A%84%E5%B1%9E%E6%80%A7%E6%95%B4%E5%90%88%E7%94%9F%E6%88%90xml%E6%96%87%E4%BB%B6%E5%B0%81%E8%A3%85%0A1.%20%E5%AE%89%E8%A3%85%20xml%E6%96%87%E4%BB%B6%E5%92%8Cjs%E6%96%87%E4%BB%B6%E4%BA%92%E8%BD%AC%20%E6%A8%A1%E5%9D%97%0A%20%20%20%20-%20%60cnpm%20i%20xml-js%20-S%60%0A%60%60%60js%0A%2F%2F%20goods-admin%2Ftools%2Ftools.js%0Avar%20convert%20%3D%20require('xml-js')%0Aexports.getXml%20%3D%20(M%2C%20sign)%20%3D%3E%20%7B%0A%20%20%20%20const%20obj%20%3D%20%7B%0A%20%20%20%20%20%20xml%3A%20%7B%0A%20%20%20%20%20%20%20%20...M%2C%0A%20%20%20%20%20%20%20%20sign%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20const%20xml%20%3D%20convert.js2xml(obj%2C%20%7B%0A%20%20%20%20%20%20compact%3A%20true%0A%20%20%20%20%7D)%0A%20%20%20%20return%20xml%20%0A%7D%0A%60%60%60%0A%0A%23%23%205.%20%E4%BD%BF%E7%94%A8axios%E5%8F%91%E8%B5%B7%20%E7%BB%9F%E4%B8%80%E4%B8%8B%E5%8D%95%E6%8E%A5%E5%8F%A3%20%E8%AF%B7%E6%B1%82%0A1.%20%E4%B8%8B%E8%BD%BDaxios%0A%20%20%20%20-%20%60npm%20i%20axios%20-S%60%0A%0A2.%20%E8%AF%B7%E6%B1%82%E7%BB%9F%E4%B8%80%E4%B8%8B%E5%8D%95%E6%8E%A5%E5%8F%A3%EF%BC%8C%E5%BE%97%E5%88%B0%E6%94%AF%E4%BB%98%E5%9C%B0%E5%9D%80%EF%BC%8C%E8%BD%AC%E6%88%90%E4%BA%8C%E7%BB%B4%E7%A0%81%E5%BD%A2%E5%BC%8F%EF%BC%8C%E8%BF%94%E5%9B%9E%E7%BB%99%E5%89%8D%E7%AB%AF%0A%60%60%60js%0Aaxios.post(config.unifiedorder%2C%20data).then(response%20%3D%3E%20%7B%0A%20%20%20%20console.log(response.data)%0A%20%20%20%20const%20xml%20%3D%20response.data%0A%0A%20%20%20%20%2F%2F%20xml%20%E8%BD%AC%E4%B8%BA%20js%E6%96%87%E4%BB%B6%20%E8%8E%B7%E5%8F%96%20code_url%20%E7%9A%84%E5%80%BC%0A%20%20%20%20const%20payObj%20%3D%20tools.xml2js(xml)%0A%20%20%20%20const%20code_url%20%3D%20payObj.code_url%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20%E6%94%AF%E4%BB%98%E5%9C%B0%E5%9D%80%20%20--%20%20%E8%BD%AC%E6%8D%A2%E4%B8%BA%E4%BA%8C%E7%BB%B4%E7%A0%81%0A%20%20%20%20qrcode.toDataURL(code_url%2C%20(err%2C%20data)%20%3D%3E%20%7B%0A%20%20%20%20%20%20res.send(%7B%0A%20%20%20%20%20%20%20%20code%3A%20'200'%2C%0A%20%20%20%20%20%20%20%20message%3A%20'%E6%94%AF%E4%BB%98%E4%BA%8C%E7%BB%B4%E7%A0%81'%2C%0A%20%20%20%20%20%20%20%20data%0A%20%20%20%20%20%20%7D)%0A%20%20%20%20%7D)%0A%7D)%0A%60%60%60%0A%0A%23%23%206.%20%E6%80%BB%E7%BB%93%0A1.%20%E5%95%86%E6%88%B7%E4%BF%A1%E6%81%AF%EF%BC%9Aconfig%2Findex.js%0A%60%60%60js%0Amodule.exports%20%3D%20%7B%0A%20%20%2F%2F%20%E7%BB%9F%E4%B8%80%E4%B8%8B%E5%8D%95%E6%8E%A5%E5%8F%A3%E5%9C%B0%E5%9D%80%0A%20%20unifiedorder%3A%20'https%3A%2F%2Fapi.mch.weixin.qq.com%2Fpay%2Funifiedorder'%2C%0A%20%20%2F%2F%20%E5%85%AC%E4%BC%97%E8%B4%A6%E5%8F%B7ID%0A%20%20appid%3A%20'wx100749d4612ea385'%2C%0A%20%20%2F%2F%20%E5%95%86%E6%88%B7%E5%8F%B7%0A%20%20mch_id%3A%20'1448624302'%2C%0A%20%20%2F%2F%20%E6%94%AF%E4%BB%98%E7%BB%93%E6%9E%9C%E7%9A%84%E5%9B%9E%E8%B0%83%E5%9C%B0%E5%9D%80%0A%20%20notify_url%3A%20'https%3A%2F%2Fwalter666.cn%2Fwxpay%2Fnotify'%2C%0A%20%20%2F%2F%20%E6%8B%BC%E6%8E%A5API%E5%AF%86%E9%92%A5%0A%20%20key%3A%20'T8NHKqOfKWtqZPnQm8K77PtQtaRXluU8'%0A%7D%0A%60%60%60%0A2.%20%E5%B7%A5%E5%85%B7%E6%96%87%E4%BB%B6%EF%BC%9Atools%2Ftools.js%0A%60%60%60js%0Avar%20rendomstring%20%3D%20require('randomstring')%20%20%2F%2F%20%E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%0Avar%20qs%20%3D%20require('querystring')%20%20%20%20%20%2F%2F%20%E8%A7%A3%E6%9E%90query%E6%95%B0%E6%8D%AE%0Avar%20md5%20%3D%20require('md5')%20%20%20%20%20%20%20%20%2F%2F%20md5%E5%8A%A0%E5%AF%86%0Avar%20config%20%3D%20require('.%2F..%2Fconfig')%20%20%20%20%20%2F%2F%20%E5%95%86%E6%88%B7%E7%9A%84%E8%BA%AB%E4%BB%BD%E4%BF%A1%E6%81%AF%0Avar%20convert%20%3D%20require('xml-js')%20%20%20%20%20%2F%2F%20xml%20%3C%3D%3D%3D%3E%20js%0Amodule.exports%20%3D%20%7B%0A%20%20%2F%2F%20%E8%8E%B7%E5%8F%96%E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%0A%20%20getNonceStr%20()%20%7B%0A%20%20%20%20return%20rendomstring.generate(32)%0A%20%20%7D%2C%0A%20%20%2F%2F%20%E8%8E%B7%E5%8F%96%E7%AD%BE%E5%90%8D%0A%20%20getSign%20(M)%20%7B%0A%20%20%20%20%2F%2F%20%E5%B0%86%E9%9B%86%E5%90%88M%E5%86%85%E9%9D%9E%E7%A9%BA%E5%8F%82%E6%95%B0%E5%80%BC%E7%9A%84%E5%8F%82%E6%95%B0%E6%8C%89%E7%85%A7%E5%8F%82%E6%95%B0%E5%90%8DASCII%E7%A0%81%E4%BB%8E%E5%B0%8F%E5%88%B0%E5%A4%A7%E6%8E%92%E5%BA%8F%EF%BC%88%E5%AD%97%E5%85%B8%E5%BA%8F%EF%BC%89%0A%20%20%20%20%2F%2F%20M%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20appid%2C%20mch_id%2C%20nonce_str%2C%20notify_url%2C%20trade_type%2C%20body%2C%20out_trade_no%2C%20total_fee%7D%0A%20%20%20%20%2F%2F%20return%20Object.keys(M).sort()%20%2F%2F%20%5B%22appid%22%2C%22body%22%2C%22mch_id%22%2C%22nonce_str%22%2C%22notify_url%22%2C%22out_trade_no%22%2C%22total_fee%22%2C%22trade_type%22%5D%0A%20%20%20%20const%20obj%20%3D%20Object.keys(M).sort().reduce((obj%2C%20key)%20%3D%3E%20%7B%0A%20%20%20%20%20%20obj%5Bkey%5D%20%3D%20M%5Bkey%5D%0A%20%20%20%20%20%20return%20obj%0A%20%20%20%20%7D%2C%20%7B%7D)%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20return%20obj%0A%20%20%20%20%2F%2F%20%E4%BD%BF%E7%94%A8URL%E9%94%AE%E5%80%BC%E5%AF%B9%E7%9A%84%E6%A0%BC%E5%BC%8F%EF%BC%88%E5%8D%B3key1%3Dvalue1%26key2%3Dvalue2%E2%80%A6%EF%BC%89%E6%8B%BC%E6%8E%A5%E6%88%90%E5%AD%97%E7%AC%A6%E4%B8%B2stringA%E3%80%82%0A%20%20%20%20const%20stringA%20%3D%20qs.stringify(obj%2C%20null%2C%20null%2C%20%7B%0A%20%20%20%20%20%20encodeURIComponent%3A%20(value)%20%3D%3E%20%7B%0A%20%20%20%20%20%20%20%20return%20decodeURIComponent(value)%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D)%0A%20%20%20%20%2F%2F%20appid%3Dwx100749d4612ea385%26body%3D%25E4%25B8%2580%25E7%2593%25B6%25E5%258F%25AF%25E4%25B9%2590%26mch_id%3D1448624302%26nonce_str%3DUWUUhSMOtwtlknfUvRHmWAXRaeRJhq1Y%C2%ACify_url%3Dhttps%253A%252F%252Fwalter666.cn%252Fwxpay%252Fnotify%26out_trade_no%3Daavbb__1%26total_fee%3D1%26trade_type%3DNative%0A%20%20%20%20%2F%2F%20return%20stringA%0A%20%20%20%20%2F%2F%20%E5%9C%A8stringA%E6%9C%80%E5%90%8E%E6%8B%BC%E6%8E%A5%E4%B8%8Akey%E5%BE%97%E5%88%B0%20stringSignTemp%20%E5%AD%97%E7%AC%A6%E4%B8%B2%0A%20%20%20%20const%20stringSignTemp%20%3D%20stringA%20%2B%20'%26key%3D'%20%2B%20config.key%0A%20%20%20%20%2F%2F%20stringSignTemp%E8%BF%9B%E8%A1%8CMD5%E8%BF%90%E7%AE%97%EF%BC%8C%E5%86%8D%E5%B0%86%E5%BE%97%E5%88%B0%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%89%80%E6%9C%89%E5%AD%97%E7%AC%A6%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%A4%A7%E5%86%99%EF%BC%8C%E5%BE%97%E5%88%B0sign%E5%80%BC%20signValue%E3%80%82%0A%20%20%20%20const%20signValue%20%3D%20md5(stringSignTemp).toUpperCase()%0A%20%20%20%20return%20signValue%0A%20%20%7D%2C%0A%20%20%2F%2F%20%E8%8E%B7%E5%8F%96xml%E6%95%B0%E6%8D%AE%0A%20%20getXml%20(M%2C%20sign)%20%7B%0A%20%20%20%20const%20obj%20%3D%20%7B%0A%20%20%20%20%20%20xml%3A%20%7B%0A%20%20%20%20%20%20%20%20...M%2C%0A%20%20%20%20%20%20%20%20sign%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%2F%2F%20%7B%22xml%22%3A%7B%22appid%22%3A%22wx100749d4612ea385%22%2C%22mch_id%22%3A%221448624302%22%2C%22nonce_str%22%3A%22TwlZGCT2ipT9ufBxUGN15yg1AuGudsWM%22%2C%22notify_url%22%3A%22https%3A%2F%2Fwalter666.cn%2Fwxpay%2Fnotify%22%2C%22trade_type%22%3A%22Native%22%2C%22body%22%3A%22%E4%B8%80%E7%93%B6%E5%8F%AF%E4%B9%90%22%2C%22out_trade_no%22%3A%22aavbb__1%22%2C%22total_fee%22%3A1%2C%22sign%22%3A%22DFAAA8968FD6F6BD86E998BE6AB07989%22%7D%7D%0A%20%20%20%20%2F%2F%20return%20obj%0A%20%20%20%20const%20xml%20%3D%20convert.js2xml(obj%2C%20%7B%0A%20%20%20%20%20%20compact%3A%20true%0A%20%20%20%20%7D)%0A%20%20%20%20%2F%2F%20%3Cxml%3E%3Cappid%3Ewx100749d4612ea385%3C%2Fappid%3E%3Cmch_id%3E1448624302%3C%2Fmch_id%3E%3Cnonce_str%3ElUrP3sg21DJCm0ckCe2KlQ6eB8LUE5vZ%3C%2Fnonce_str%3E%3Cnotify_url%3Ehttps%3A%2F%2Fwalter666.cn%2Fwxpay%2Fnotify%3C%2Fnotify_url%3E%3Ctrade_type%3ENative%3C%2Ftrade_type%3E%3Cbody%3E%E4%B8%80%E7%93%B6%E5%8F%AF%E4%B9%90%3C%2Fbody%3E%3Cout_trade_no%3Eaavbb__1%3C%2Fout_trade_no%3E%3Ctotal_fee%3E1%3C%2Ftotal_fee%3E%3Csign%3E002F2F7EFAB1270A093A94109D848883%3C%2Fsign%3E%3C%2Fxml%3E%0A%20%20%20%20return%20xml%20%0A%20%20%7D%2C%0A%20%20%2F%2F%20%E5%B0%86xml%E6%95%B0%E6%8D%AE%E8%BD%AC%E6%88%90js%E6%95%B0%E6%8D%AE%0A%20%20xml2js%20(xml)%20%7B%0A%20%20%20%20const%20obj%20%3D%20convert.xml2js(xml%2C%20%7B%0A%20%20%20%20%20%20compact%3A%20true%2C%0A%20%20%20%20%20%20textKey%3A%20'value'%2C%0A%20%20%20%20%20%20cdataKey%3A%20'value'%0A%20%20%20%20%7D)%0A%20%20%20%20%0A%20%20%20%20%2F%2F%20return%20obj%0A%20%20%20%20const%20dataObjArr%20%3D%20Object.keys(obj.xml).sort()%0A%20%20%20%20%2F%2F%20%5B%22appid%22%2C%22code_url%22%2C%22mch_id%22%2C%22nonce_str%22%2C%22prepay_id%22%2C%22result_code%22%2C%22return_code%22%2C%22return_msg%22%2C%22sign%22%2C%22trade_type%22%5D%0A%20%20%20%20const%20dataObj%20%3D%20dataObjArr.reduce((obj1%2C%20key)%20%3D%3E%20%7B%0A%20%20%20%20%20%20obj1%5Bkey%5D%20%3D%20obj.xml%5Bkey%5D%5B'value'%5D%0A%20%20%20%20%20%20return%20obj1%0A%20%20%20%20%7D%2C%20%7B%7D)%0A%20%20%20%20%0A%20%20%20%20return%20dataObj%0A%20%20%7D%0A%7D%0A%60%60%60%0A%0A3.%20%E6%8E%A5%E5%8F%A3%E6%96%87%E4%BB%B6%EF%BC%9Aapi%2Forder.js%0A%60%60%60js%0Avar%20config%20%3D%20require('.%2F..%2Fconfig')%20%20%20%20%20%2F%2F%20%E5%95%86%E6%88%B7%E7%9A%84%E8%BA%AB%E4%BB%BD%E4%BF%A1%E6%81%AF%0Avar%20tools%20%3D%20require('.%2F..%2Futils%2Ftools')%20%20%20%20%20%2F%2F%20%E5%B7%A5%E5%85%B7%E6%96%87%E4%BB%B6%0Avar%20axios%20%3D%20require('axios')%20%20%20%20%20%20%20%20%2F%2F%20%E6%95%B0%E6%8D%AE%E8%AF%B7%E6%B1%82%0Avar%20qrcode%20%3D%20require('qrcode')%20%20%20%20%20%20%2F%2F%20%E5%9C%B0%E5%9D%80%E8%BD%AC%E6%88%90%E4%BA%8C%E7%BB%B4%E7%A0%81%0Arouter.get('%2Fpayment'%2C%20(req%2C%20res%2C%20next)%20%3D%3E%20%7B%0A%20%20let%20%7B%20body%2C%20out_trade_no%2C%20total_fee%20%7D%20%3D%20req.query%0A%20%20body%20%3D%20%22%E4%B8%80%E7%93%B6%E5%8F%AF%E4%B9%90%22%20%2F%2F%20%E5%95%86%E5%93%81%E6%8F%8F%E8%BF%B0%0A%20%20out_trade_no%20%3D%20%22aabbcc_1%22%20%2F%2F%20%E5%95%86%E6%88%B7%E7%9A%84%E8%AE%A2%E5%8D%95%E7%BC%96%E5%8F%B7%0A%20%20total_fee%20%3D%201%20%2F%2F%20%E6%94%AF%E4%BB%98%E9%87%91%E9%A2%9D%EF%BC%8C%E5%88%86%0A%0A%20%20const%20appid%20%3D%20config.appid%20%20%20%20%20%2F%2F%20%E5%85%AC%E4%BC%97%E5%8F%B7id%0A%20%20const%20mch_id%20%3D%20config.mch_id%20%20%20%2F%2F%20%E5%95%86%E6%88%B7%E5%8F%B7%0A%20%20const%20nonce_str%20%3D%20%20tools.getNonceStr()%09%20%2F%2F%20%E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%20randomstring%0A%20%20const%20notify_url%20%3D%20config.notify_url%20%2F%2F%20%E6%94%AF%E4%BB%98%E7%BB%93%E6%9E%9C%E7%9A%84%E5%9B%9E%E8%B0%83%E5%9C%B0%E5%9D%80%0A%20%20const%20trade_type%20%3D%20%22NATIVE%22%09%2F%2F%20%E4%BA%A4%E6%98%93%E7%B1%BB%E5%9E%8B%0A%20%20%2F%2F%20%E8%AE%BE%E6%89%80%E6%9C%89%E5%8F%91%E9%80%81%E6%88%96%E8%80%85%E6%8E%A5%E6%94%B6%E5%88%B0%E7%9A%84%E6%95%B0%E6%8D%AE%E4%B8%BA%E9%9B%86%E5%90%88M%EF%BC%8C%0A%20%20const%20M%20%3D%20%7B%0A%20%20%20%20appid%2C%20mch_id%2C%20nonce_str%2C%20notify_url%2C%20trade_type%2C%20body%2C%20out_trade_no%2C%20total_fee%0A%20%20%7D%0A%20%20const%20sign%20%3D%20tools.getSign(M)%20%20%2F%2F%20%E7%AD%BE%E5%90%8D%0A%0A%20%20%2F%2F%20%E5%8F%82%E6%95%B0%E8%BD%AC%E6%8D%A2%E6%88%90%E4%B8%BAxml%E6%96%87%E4%BB%B6%EF%BC%8C%E6%94%AF%E4%BB%98%20%E5%8F%82%E6%95%B0%E5%BD%A2%E5%BC%8F%E4%B8%BAxml%E6%A0%BC%E5%BC%8F%20%20---%20%20%E5%AF%B9%E8%B1%A1%E7%9A%84key%E5%80%BC%E4%B8%BA%E6%A0%87%E7%AD%BE%EF%BC%8Cvalue%E7%9A%84%E5%80%BC%E4%B8%BA%20%E6%A0%87%E7%AD%BE%E7%9A%84%E5%86%85%E5%AE%B9%0A%20%20%2F%2F%20%E8%B0%83%E7%94%A8%E6%8E%A5%E5%8F%A3%E9%9C%80%E8%A6%81%E4%BC%A0%E9%80%92%E7%9A%84%E6%95%B0%E6%8D%AE%0A%20%20const%20data%20%3D%20tools.getXml(M%2C%20sign)%0A%20%20axios.post(config.unifiedorder%2C%20data).then(response%20%3D%3E%20%7B%0A%20%20%20%20console.log(response.data)%0A%20%20%20%20const%20xml%20%3D%20response.data%0A%0A%20%20%20%20%2F%2F%20xml%20%E8%BD%AC%E4%B8%BA%20js%E6%96%87%E4%BB%B6%20%E8%8E%B7%E5%8F%96%20code_url%20%E7%9A%84%E5%80%BC%0A%20%20%20%20const%20payObj%20%3D%20tools.xml2js(xml)%0A%20%20%20%20const%20code_url%20%3D%20payObj.code_url%0A%0A%20%20%20%20%2F%2F%20%E6%94%AF%E4%BB%98%E5%9C%B0%E5%9D%80%20%20--%20%20%E8%BD%AC%E6%8D%A2%E4%B8%BA%E4%BA%8C%E7%BB%B4%E7%A0%81%0A%20%20%20%20qrcode.toDataURL(code_url%2C%20(err%2C%20data)%20%3D%3E%20%7B%0A%20%20%20%20%20%20res.send(%7B%0A%20%20%20%20%20%20%20%20state%3A%20'200'%2C%0A%20%20%20%20%20%20%20%20title%3A%20'%E6%94%AF%E4%BB%98%E4%BA%8C%E7%BB%B4%E7%A0%81'%2C%0A%20%20%20%20%20%20%20%20data%0A%20%20%20%20%20%20%7D)%0A%20%20%20%20%7D)%0A%20%20%7D)%0A%7D)%0A%60%60%60%0A%0A%0A%23%20%E4%BA%8C%E3%80%81%E5%89%8D%E7%AB%AF%E8%B0%83%E7%94%A8%E6%8E%A5%E5%8F%A3%0A1.%20%E5%B0%81%E8%A3%85%E6%8E%A5%E5%8F%A3%E6%96%B9%E6%B3%95%0A%0A2.%20%E5%8E%BB%E6%94%AF%E4%BB%98%E9%A1%B5%E9%9D%A2%EF%BC%8C%E5%BC%95%E5%85%A5%E6%96%B9%E6%B3%95%0A%0A3.%20%E7%82%B9%E5%87%BB%E6%94%AF%E4%BB%98%EF%BC%8C%E8%B0%83%E7%94%A8%E6%96%B9%E6%B3%95%EF%BC%8C%E5%8F%91%E9%80%81%E6%95%B0%E6%8D%AE%0A%20%20%20%20-%20body%EF%BC%9A%E5%95%86%E5%93%81%E6%8F%8F%E8%BF%B0%0A%20%20%20%20-%20out_trade_no%EF%BC%9A%E8%AE%A2%E5%8D%95%E7%BC%96%E5%8F%B7%0A%20%20%20%20-%20total_fee%EF%BC%9A%E4%BB%98%E6%AC%BE%E9%87%91%E9%A2%9D%EF%BC%8C%E5%88%86%0A%0A</center></body></html>